package com.clqteam.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.clqteam.dao.showShNameDao;
import com.clqteam.model.Supplier;
import com.clqteam.service.showShNameService;
import com.clqteam.serviceimpl.showShNameServiceImpl;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class showShNameController extends HttpServlet{
	showShNameService  shs = new showShNameServiceImpl();
	      @Override
	    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	    	  doPost(req, resp);
	    }
	      
	      
	      @Override
	    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	    	  req.setCharacterEncoding("utf8");
	    	     resp.setCharacterEncoding("utf8");
	    	     List<Supplier> sname = shs.findrNameByEmployee();
	    	     JSONArray js = new JSONArray();
	    	     for (Supplier Supplier : sname) {
					JSONObject j = new JSONObject();
					j.put("rtext", Supplier.getSupName());
					j.put("supId", Supplier.getSupId());
				}
	    	     PrintWriter pw = resp.getWriter();
	    	     pw.write(js.toString());
	    	     pw.flush();
	    	     pw.close();
	    	  
	    }

}